home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / src / netlib / sana2printfault.c < prev    next >
C/C++ Source or Header  |  1994-03-24  |  2KB  |  84 lines

  1. RCS_ID_C="$Id: sana2printfault.c,v 1.3 1994/03/24 17:04:36 jraja Exp $";
  2. /*
  3.  * sana2printfault.c --- print SANA-II error message
  4.  *
  5.  * Author: ppessi <Pekka.Pessi@hut.fi>
  6.  *
  7.  * Copyright © 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
  8.  *                  Helsinki University of Technology, Finland.
  9.  *                  All rights reserved.
  10.  *
  11.  * Created      : Sat Mar 20 02:10:14 1993 ppessi
  12.  * Last modified: Thu Mar 24 06:42:21 1994 ppessi
  13.  */
  14.  
  15. #include <devices/sana2.h>
  16. #include <net/sana2errno.h>
  17. #ifdef __SASC 
  18. #include <proto/dos.h>
  19. #else
  20. #include <clib/dos_protos.h>
  21. #endif
  22.  
  23. /****** sana2.lib/sana2PrintFault *********************************************
  24.  
  25.     NAME
  26.     Sana2PrintFault - print SANA-II device error messages
  27.  
  28.     SYNOPSIS
  29.     #include <devices/sana2.h>
  30.  
  31.     Sana2PrintFault(banner, ios2request)
  32.  
  33.     void Sana2PrintFault(const char *, struct IOSana2Req *)
  34.  
  35.     FUNCTION
  36.     The Sana2PrintFault() function finds the error message corresponding
  37.     to the error in the given SANA-II IO request and writes it, followed
  38.     by a newline, to the Output().  If the argument string is non-NULL it
  39.     is preappended to the message string and separated from it by a colon
  40.     and space (`: ').  If string is NULL only the error message string is
  41.     printed.
  42.  
  43.     SEE ALSO
  44.     Sana2PrintFault()
  45.  
  46. *******************************************************************************
  47. */
  48.  
  49.  
  50. void 
  51. Sana2PrintFault(const char *banner, struct IOSana2Req *ios2)
  52. {
  53.   register WORD err = ios2->ios2_Req.io_Error;
  54.   register ULONG werr = ios2->ios2_WireError;
  55.   LONG args[3];
  56.   char * format;
  57.  
  58.   args[0] = (LONG)banner; 
  59.  
  60.   if (err >= sana2io_nerr || -err > io_nerr) {
  61.     args[1] = (LONG)io_errlist[0];
  62.   } else { 
  63.     if (err < 0) 
  64.       args[1] = (LONG)io_errlist[-err];
  65.     else 
  66.       args[1] = (LONG)sana2io_errlist[err];
  67.   }
  68.   if (werr == 0 || werr >= sana2wire_nerr) {
  69.     if (banner != NULL)
  70.       format = "%s: %s\n";
  71.     else
  72.       format = "%s\n";
  73.   } else {
  74.     if (banner != NULL)
  75.       format = "%s: %s (%s)\n";
  76.     else
  77.       format = "%s (%s)\n";
  78.     args[2] = (LONG)sana2wire_errlist[werr];
  79.   }
  80.  
  81.   VPrintf(format, banner != NULL ? args : args + 1);
  82. }
  83.  
  84.